//
//  EmumsBootcamp.swift
//  swiftUiTest
//
//  Created by Mac on 2023/6/27.
//

import SwiftUI

struct Init_EmumsBootcamp_02: View {
    
    let backgroundColor: Color ;
    let count: Int
    let title: String
    
    init(count: Int, fruit:Fruit) {
       
        self.count = count
      
        if(fruit == .apple){
            self.title = "apple"
            self.backgroundColor = .blue
        }else{
            self.title = "orange"
            self.backgroundColor  = .green
        }
    }
    
    enum Fruit{
        case apple
        case orange
    }
    
    
    var body: some View {
        VStack(spacing:12) {
            Text("\(count)")
                .font(.largeTitle)
                .foregroundColor(.white)
                .underline()
            Text("\(title)")
                .font(.headline)
                .foregroundColor(.white)
        }
        .frame(width: 150,height: 150)
        .background(backgroundColor)
        .cornerRadius(10)
    }
}

struct EmumsBootcamp_Previews: PreviewProvider {
    static var previews: some View {
        HStack {
            Init_EmumsBootcamp_02(count: 6,fruit: .apple)
            Init_EmumsBootcamp_02(count: 10,fruit:.orange)
        }
    }
}
